//
//  NoticeDetailViewController.m
//  JimiPay
//
//  Created by yull on 16/1/7.
//  Copyright (c) 2016年 com.shengyun. All rights reserved.
//

#import "NoticeDetailViewController.h"

@interface NoticeDetailViewController ()

@end

@implementation NoticeDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.navigationItem.title = @"公告详情";
    [self setupCustomBackItem];
    
    NSString *title = [self.noticeDic objectForKey:@"noticeTitle"];
    if (![title isKindOfClass:[NSString class]]) {
        title = @"--";
    }
    self.titleL.text = title;
    
    NSString *content = [self.noticeDic objectForKey:@"noticeBody"];
    if (![content isKindOfClass:[NSString class]]) {
        content = @"--";
    }
//    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[content dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
//    self.contentL.attributedText = attrStr;
    self.contentL.text = content;
    [self.contentL sizeToFit];
    //    CGRect frame = self.contentL.frame;
    //    frame.size.height = frame.size.height < 54 ? 54 : frame.size.height;
    //    self.contentL.frame = frame;
    
    NSString *time = [self.noticeDic objectForKey:@"createDate"];
    if (![time isKindOfClass:[NSString class]]) {
        time = @"--";
    } else {
        time = [NSString stringWithFormat:@"%@月%@日 %@:%@:%@",
                [time substringWithRange:NSMakeRange(4, 2)],
                [time substringWithRange:NSMakeRange(6, 2)],
                [time substringWithRange:NSMakeRange(8, 2)],
                [time substringWithRange:NSMakeRange(10, 2)],
                [time substringWithRange:NSMakeRange(12, 2)]];
    }
    self.timeL.text = time;
    
    CGRect frame = self.timeL.frame;
    frame.origin.y = CGRectGetMaxY(self.contentL.frame) + 3;
    self.timeL.frame = frame;
    
    frame = self.detailView.frame;
    frame.size.height = CGRectGetMaxY(self.timeL.frame) + 3;
    self.detailView.frame = frame;
}

@end
